package com.li.learning.train.controller;


import com.li.learning.train.model.dto.CommitTrainDto;
import com.li.learning.train.model.dto.TrainDetailDto;
import com.li.learning.train.service.TrainService;
import com.our.learning.infrastructure.constant.ResponseStatusEnum;
import com.our.learning.infrastructure.pojo.Response;
import com.our.learning.infrastructure.pojo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @author :leapzed
 * @date : 2023-06-24
 */
@RestController
@RequestMapping("/train")
public class TrainController {

    @Autowired
    private TrainService trainService;

    /**
     * 生成巩固练习
     * @param stuId
     */
    @GetMapping("/generate")
    public ResponseResult generateTrain(@RequestParam Integer stuId){
        return ResponseResult.okResult(trainService.generateTrain(stuId));
    }

    /**
     * 学生提交巩固训练答题，并返回答案解析
     * @param dto
     * @return
     */
    @PostMapping("/submit")
    public ResponseResult submitTrain(@RequestBody CommitTrainDto dto){
        return ResponseResult.okResult(trainService.submitTrain(dto));
    }

    /**
     * 根据训练时间由近到远排序获取训练列表
     * @param pageNum
     * @param pageSize
     * @param stuId
     * @return
     */
    @GetMapping("/list")
    public ResponseResult getList(Integer pageNum,Integer pageSize,Integer stuId){
        return ResponseResult.okResult(trainService.getList(pageNum,pageSize,stuId));
    }

    /**
     * 获取巩固训练详情
     * @param trainId
     * @return
     */
    @GetMapping("/detail")
    public ResponseResult getDetail(Integer trainId){
        return ResponseResult.okResult(trainService.getDetail(trainId));
    }


}
